%!TEX root = ../bare_adv.tex
\subsection{Processing of Sensor Data}
When a reader detects an object it records it in a log. 
This reading is of the following format $\langle readerID,objectID,t\rangle$.
The \textit{readerID} is the identity of the reader, \textit{objectID} is the identity of the object which is in the range of the reader, and $t$ is the timestamp of when reader detect the object.
This recording is done at a given sampling rate. 
The same object may be recorded several times by the same reader in a row. 
A reader creates a log entry for each object that is in the vicinity of the reader thus there can be several log entries with the same timestamp.

The data is processed such that an online and an offline output are generated.
This happens the following way.
All data from the readers are continuously streamed to a shared database that is responsible for maintaining the data.
If an object enters or leaves the range of a reader an online \textit{output} is generated, this have the form:
\begin{align}
\label{log:online}
\langle readerID,objectID,t,flag \rangle
\end{align}
where \textit{flag} is ``START'' or ``END'' respectively. 
%When the object is no longer detected by the reader an output is generated. 
Note that when an object is no longer in vicinity of the reader the $flag$ of the last entry is set to ``END'' and $t$ is the last timestamp where the object was within the vicinity.
The second output, offline output, is generated it have the from:
\begin{align}
\label{log:offline}
\langle readerID,objectID,t_{first},t_{last} \rangle
\end{align}
Where $t_{first}$ and $t_{last}$ is the timestamp of the device entry and exit of the readers vicinity.
%The two outputs ((\ref{log:online}) and (\ref{log:offline})) are used in online and offline tracking which we cover in Section~\ref{sub:online} and Section~\ref{sub:offline}.

 
